<template>
  <div class="container">
    <div class="app-container">
      <el-tree :data="depts" :props="defaultProps">
        <template #default="{ data }">
          <el-row style="width:100%">
            <el-col :span="20">{{ data.name }}</el-col>
            <el-col :span="4">
              <el-row>
                <el-col :span="12">{{ data.managerName||'管理员' }}</el-col>
                <el-col :span="12">操作</el-col>
              </el-row>
            </el-col>
          </el-row>
        </template>
      </el-tree>
    </div>
  </div>
</template>
<script>
import { getDepartmentList } from '@/api/dapartment'
import { trans2TreeList } from '@/utils'

export default {
  name: 'Department',
  data() {
    return {
      depts: [{
        name: '传智教育',
        controller: 'admin',
        children: [
          { name: '总裁办',
            children: [
              { name: '行政部' },
              { name: '财务部' }
            ]
          },
          { name: '行政部' },
          { name: '财务部' }
        ]
      }],
      defaultProps: {
        children: 'children',
        label: 'name'
      }
    }
  },
  created() {
    this.getDep()
  },
  methods: {
    getDep() {
      getDepartmentList().then(res => {
        console.log(res)

        this.depts = trans2TreeList(res, 0)
      })
    }
  }

}
</script>

<style lang="scss" scoped>
  .debug {
    background-color: red;
  }
</style>
